<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('选择定额工日单价')" />
</head>
<body class="gray-bg">
     <input type="hidden" id="rowIds">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								<label>月份：</label>
								<input type="text" class="time-input2" placeholder="请选择月份"  name="params[beginTime]"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			<input type="hidden" id="avgPrice"/>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var prefix = ctx + "basic/price";
		var types = [[${@dict.getType('daily_unit_price_type')}]];
        $(function() {
            var options = {
				url: prefix + "/list?type=1",
		        showSearch: false,
		        showRefresh: false,
		        showToggle: false,
		        showColumns: false,
				columns: [{
					field: 'selectItem',
					radio: true
				},
					{
						field: 'id',
						title: 'id',
						visible: false
					},
					{
						field: 'unitPriceDate',
						title: '月份'
					},
					{
						field: 'remark',
						title: '备注',
						visible: false
					},
					{
						title: '操作',
						align: 'center',
						formatter: function(value, row, index) {
							var actions = [];
							actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="view(\'' + row.id + '\')"><i class="fa fa-edit"></i>选择</a> ');
							return actions.join('');
						}
					}]
            };
            $.table.init(options);
        });

		function view(id){
			var options = {
				title: '单价明细',
				url: prefix + "/select?id="+id + "&type=1",
				width:700,
				height: 500,
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}
		function doSubmit(index, layero){
			var rows = layero.find("iframe")[0].contentWindow.getSelections();
			if (rows.length == 0) {
				$.modal.alertWarning("请至少选择一条记录");
				return;
			}
			$("#avgPrice").val(rows.price);
			var pIndex = localStorage.getItem("unitPriceRefDialogIndex")
			pIndex = parent.layer.getFrameIndex(pIndex)
			var body = $.modal.getChildFrame(pIndex);
			body.find("#fixedUnitPrice").val(rows.price)
			$.modal.close(index);
			$.modal.close();
		}
				/* 添加用户-选择用户-提交(回调形式-父页面调用子页面) */
		function getSelections() {
			var avgPrice = $("#avgPrice").val();
			return {"price":avgPrice};
		}

    </script>
</body>
</html>